<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>后面页面</title>
  <script src="js/vue.min.js"></script>
  <script src="js/jquery-1.12.4.js"></script>
</head>

<body>
  <div id="app">
    <h1>欢迎光临，{{user.username}} {{user.sex=='男'?'先生':'女士'}}</h1>
  </div>

  <script>
    new Vue({
      el: "#app",
      data: {
        user: {}
      },
      methods: {
      },
      mounted() {
        let that = this;

        let params = {
          // 方法一：参数的方式传递token
          'token': localStorage.getItem("token")
        }
        $.ajax('http://localhost:8080/jwt/api/main', {
          type: 'post',
          data: params,
          dataType: 'json',
          success: function (res) {
            console.log(res);
            that.user = res.data;


          }
        });
      }

    });
  </script>


</body>

</html>